package com.yesjpt.serv.impl;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import com.yesjpt.serv.BaseServ;
import com.yesjpt.util.L;
import com.yesjpt.util.StringUtil;

@Service
public class BaseServImpl implements BaseServ {
	
	//所有环境变量的读取
	@Value("#{@environment['isdevmode'] ?: null }")
	protected String isdevmode;

	@Value("#{@environment['testPhone'] ?: null }")
	protected String testPhone;

	@Value("#{@environment['files.rootUrl'] ?: null }")
	protected String filesRootUrl;

	@Value("#{@environment['wsBase'] ?: null }")
	protected String wsBase;


	@Value("#{@environment['files.rootPath'] ?: null }")
	protected String filesRootPath;

	@Value("#{@environment['copyright'] ?: null }")
	protected String copyright;

	@Value("#{@environment['appName'] ?: null }")
	protected String appName;

	@Value("#{@environment['serviceUrl'] ?: null }")
	protected String serviceUrl;

	@Value("#{@environment['appAlias'] ?: null }")
	protected String appAlias;

	@Value("#{@environment['dbSchema'] ?: null }")
	protected String dbSchema;

	@Value("#{@environment['dbServer'] ?: null }")
	protected String dbServer;

	public static String genGuid() {
		return StringUtil.genGuid();
	}

	public static Boolean isnull(Object o) {
		return o == null || o.toString().length() == 0;
	}
	
	@Override
	public JSONObject getConfig() {
		L.info(new Throwable().getStackTrace()[0]);
		JSONObject o = new JSONObject();
		o.put("filesRootUrl", filesRootUrl);
		o.put("filesRootPath", filesRootPath);
		o.put("copyright", copyright);
		o.put("appName", appName);
		o.put("serviceUrl", serviceUrl);
		o.put("appAlias", appAlias);
		o.put("dbSchema", dbSchema);
		o.put("isdevmode", isdevmode);
		o.put("wsBase", wsBase);
		o.put("hello", "大家早上好！一会儿要下课了。。。。");
		return o;
	}

}
